#pragma once

#include "Types.h"

namespace Vortex { namespace Wrapper { namespace Direct3D {

	///<summary>Enumeration of device capabilities</summary>
	[Flags]
	public enum struct  D3DDeviceCaps {
		NONE = 0,
		EXECUTESYSTEMMEMORY   = 0x00000010L, /* Device can use execute buffers from system memory */
		EXECUTEVIDEOMEMORY    = 0x00000020L, /* Device can use execute buffers from video memory */
		TLVERTEXSYSTEMMEMORY  = 0x00000040L, /* Device can use TL buffers from system memory */
		TLVERTEXVIDEOMEMORY   = 0x00000080L, /* Device can use TL buffers from video memory */
		TEXTURESYSTEMMEMORY   = 0x00000100L, /* Device can texture from system memory */
		TEXTUREVIDEOMEMORY    = 0x00000200L, /* Device can texture from device memory */
		DRAWPRIMTLVERTEX      = 0x00000400L, /* Device can draw TLVERTEX primitives */
		CANRENDERAFTERFLIP    = 0x00000800L, /* Device can render without waiting for flip to complete */
		TEXTURENONLOCALVIDMEM  = 0x00001000L, /* Device can texture from nonlocal video memory */
		DRAWPRIMITIVES2       = 0x00002000L, /* Device can support DrawPrimitives2 */
		SEPARATETEXTUREMEMORIES  = 0x00004000L, /* Device is texturing from separate memory pools */
		DRAWPRIMITIVES2EX     = 0x00008000L, /* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*/
		HWTRANSFORMANDLIGHT   = 0x00010000L, /* Device can support transformation and lighting in hardware and DRAWPRIMITIVES2EX must be also */
		CANBLTSYSTONONLOCAL   = 0x00020000L, /* Device supports a Tex Blt from system memory to non-local vidmem */
		HWRASTERIZATION       = 0x00080000L, /* Device has HW acceleration for rasterization */
		PUREDEVICE            = 0x00100000L, /* Device supports D3DCREATE_PUREDEVICE */
		QUINTICRTPATCHES      = 0x00200000L, /* Device supports quintic Beziers and BSplines */
		RTPATCHES             = 0x00400000L, /* Device supports Rect and Tri patches */
		RTPATCHHANDLEZERO     = 0x00800000L, /* Indicates that RT Patches may be drawn efficiently using handle 0 */
		NPATCHES              = 0x01000000L /* Device supports N-Patches */
	};

	///<summary>Enumeration of texture capabilities</summary>
	[Flags]
	public enum struct D3DTextureCaps {
		NONE = 0,
		PERSPECTIVE =       0x00000001L, /* Perspective-correct texturing is supported */
		POW2 =              0x00000002L, /* Power-of-2 texture dimensions are required - applies to non-Cube/Volume textures only. */
		ALPHA =             0x00000004L, /* Alpha in texture pixels is supported */
		SQUAREONLY =        0x00000020L, /* Only square textures are supported */
		TEXREPEATNOTSCALEDBYSIZE = 0x00000040L, /* Texture indices are not scaled by the texture size prior to interpolation */
		ALPHAPALETTE =      0x00000080L, /* Device can draw alpha from texture palettes */
		NONPOW2CONDITIONAL =0x00000100L,
		PROJECTED =         0x00000400L, /* Device can do D3DTTFF_PROJECTED */
		CUBEMAP =           0x00000800L, /* Device can do cubemap textures */
		VOLUMEMAP =         0x00002000L, /* Device can do volume textures */
		MIPMAP =            0x00004000L, /* Device can do mipmapped textures */
		MIPVOLUMEMAP =      0x00008000L, /* Device can do mipmapped volume textures */
		MIPCUBEMAP =        0x00010000L, /* Device can do mipmapped cube maps */
		CUBEMAP_POW2 =      0x00020000L, /* Device requires that cubemaps be power-of-2 dimension */
		VOLUMEMAP_POW2 =    0x00040000L, /* Device requires that volume maps be power-of-2 dimension */
		NOPROJECTEDBUMPENV =0x00200000L /* Device does not support projected bump env lookup operation */
	};

	public value struct D3DCaps {
		DWORD   MaxTextureWidth, MaxTextureHeight;
		DWORD   MaxTextureRepeat;
		DWORD	MaxTextureAspectRatio;
		DWORD   MaxDrawPrimitive;

		D3DDeviceCaps	DevCaps;
		D3DTextureCaps  TextureCaps;


		D3DCaps(D3DCAPS9* pCaps) {
			MaxTextureWidth = pCaps->MaxTextureWidth;
			MaxTextureHeight = pCaps->MaxTextureHeight;
			MaxTextureRepeat = pCaps->MaxTextureRepeat;
			MaxDrawPrimitive = pCaps->MaxPrimitiveCount;
			MaxTextureAspectRatio = pCaps->MaxTextureAspectRatio;
			DevCaps = (D3DDeviceCaps)pCaps->DevCaps;
			TextureCaps = (D3DTextureCaps)pCaps->TextureCaps;
		}
	};

} } }